package kr.co.example.newgugudan;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.util.Log;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class GugudanClick extends Activity  { 
  int num;
  int j;
  TextView prn_text;    
  EditText input_btn; 
  Button out_btn; 
  String Result;
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.gugudan);  
   
         out_btn = (Button)findViewById(R.id.out_btn); 
         input_btn =(EditText)findViewById(R.id.input_btn);
         prn_text=(TextView)findViewById(R.id.prn_text11);
         input_btn.setFocusable(false);
      	 input_btn.setClickable(false);
     	 input_btn.setFocusableInTouchMode(false);
  }

  /*if((num*j)<10){ 
	Result=String.format(" ");             
	}else{            
		Result=String.format("");
	           } */
/*  public static void printing(int x, int y) {
	     if((x*y) < 10)
	      
	      System.out.print(x + "x" + y + "=0" + x*y + "\t");       
	     else
	      System.out.print(x + "x" + y + "=" + x*y + "\t");       
	  }
	}*/
public void mOnClick(View v) {
	 
	switch(v.getId()){
 	case R.id.out_btn:
	 	 Result="";
	 	  if(v.getId()==R.id.out_btn){   
	 		 try{
	 			num = Integer.parseInt(input_btn.getText().toString()); 
	 			}catch(Exception e){
	 				Toast.makeText(this, "다른 숫자를 입력하세요", Toast.LENGTH_SHORT).show();
	 			}//try의 끝
	 	   for(j = 1 ;j<10;j++){  
	 	     Result=Result+"\n"+String.format("%d",num)+" X "+
	 	     String.format("%d",j)+" = "+String.format("%d",num*j);
	 	   }//for문 끝
	 	     prn_text.setText(Result);  
	 	     input_btn.setText("");
	 	   }//if의 끝
	 	  /* else if((num*j)>10){
	 		  for(j = 1 ;0<num &&j<10;j++){  
	 	 	     Result=Result+"\n"+String.format("%d",num)+" X "+
	 	 	     String.format("%d",j)+" = "+String.format("%2d",num*j);*/
	 	   
	 	  
	 	  break;
	 	case R.id.dele_btn:
	 		prn_text.setText("");
			Editable edit = input_btn.getText();
			int std = edit.length();
			if (std > 1) {
				edit.delete(std-1, std);
				input_btn.setText(edit);
			} else 	if (std <= 1) {
				input_btn.setText("");
			} break;
	 	case R.id.button1_011:
			String text1=input_btn.getText().toString();
			input_btn.setText(text1+"1"+"");
			break;
		case R.id.button2_022:
			String text2=input_btn.getText().toString();
			input_btn.setText(text2+"2"+"");
			break;
		case R.id.button3_033:
			String text3=input_btn.getText().toString();
			input_btn.setText(text3+"3"+"");
			break;
		case R.id.button4_044:
			String text4=input_btn.getText().toString();
			input_btn.setText(text4+"4"+"");
			break;
		case R.id.button5_055:
			String text5=input_btn.getText().toString();
			input_btn.setText(text5+"5"+"");
			break;
		case R.id.button6_066:
			String text6=input_btn.getText().toString();
			input_btn.setText(text6+"6"+"");
			break;
		case R.id.button7_077:
			String text7=input_btn.getText().toString();
			input_btn.setText(text7+"7"+"");
			break;
		case R.id.button8_088:
			String text8=input_btn.getText().toString();
			input_btn.setText(text8+"8"+"");
			break;
		case R.id.button9_099:
			String text9=input_btn.getText().toString();
			input_btn.setText(text9+"9"+"");
			break;
		case R.id.button10_100:
			String text10=input_btn.getText().toString();
			input_btn.setText(text10+"0"+"");
			break;
	 }
   }
}

